home *** CD-ROM | disk | FTP | other *** search
/ Hráč 2004 August / Hrac_72_2004-08_dvd.iso / dema / Rapid Gun / rg_setup.exe / common / cdiffuse_lmap.fx < prev    next >
Text File  |  2004-05-10  |  4KB  |  148 lines

  1. // LF2 Engine
  2. // (C) 2002-3 7FX
  3. //---------------------------------------------------------------------------
  4. #include "common.fxh"
  5. //---------------------------------------------------------------------------
  6. // Common parameters
  7. // Desc
  8. string desc : Description = "Mapuje konstantni barvu s lighmapou na mesh.";
  9. // Requirements
  10. string req : Requirements = "Diffuse, lightmap";
  11. // vertex format
  12. string vf : VertexFormat = "POSITION | LIGHTMAP"; // 257 (for export) 
  13. //---------------------------------------------------------------------------
  14. // Used constants
  15. const matrix cMtxWVP : WorldViewProjection;
  16. const int cAlphaRef : AlphaRef = 0;
  17. // Diffuse color, default white
  18. const float4 cDiffuse : Diffuse = {1.f, 1.f, 1.f, 1.f};
  19. // CullMode - NONE=1, CW=2, CCW=3
  20. const int cCullMode : CullMode = 3; // default CCW
  21. // Matrices for fixed function technique
  22. const matrix cMtxW : World;
  23. // Sampler filters
  24. DECLARE_TEX_SAMPLER_VALUES;
  25. //---------------------------------------------------------------------------
  26. // Light map texture
  27. texture2D lightmap : LightMap;
  28. //---------------------------------------------------------------------------
  29. // Light map sampler
  30. sampler lightmap_sampler = sampler_state
  31. {
  32.     Texture = <lightmap>;
  33.     //SET_TEX_SAMPLER_FILTERS;
  34.     MipFilter = NONE; 
  35.     MinFilter = <cMinFlt>; 
  36.     MagFilter = <cMagFlt>;
  37.     AddressU = CLAMP;
  38.     AddressV = CLAMP;
  39. };
  40. //---------------------------------------------------------------------------
  41. // programs
  42. struct VS_OUTPUT
  43. {
  44.     float4 Position : POSITION;
  45.     float2 LightMapCoord : TEXCOORD0;
  46. };
  47.  
  48. // vertex shader
  49. VS_OUTPUT VS(float4 Position : POSITION, float2 LightMapCoord : TEXCOORD0)
  50. {
  51.     VS_OUTPUT Out = (VS_OUTPUT)0;
  52.     Out.Position = mul(Position, cMtxWVP);
  53.     Out.LightMapCoord = LightMapCoord;
  54.     return Out;
  55. }
  56.  
  57. // pixel shader
  58. float4 PS(VS_OUTPUT In) : COLOR
  59. {
  60.     return cDiffuse * tex2D(lightmap_sampler, In.LightMapCoord);
  61. }
  62.  
  63. //---------------------------------------------------------------------------
  64. // Technique with vertex and pixel shader
  65. technique vs11_ps11
  66. <
  67.     // streams for technique
  68.     string stream1 = "POSITION | LIGHTMAP";
  69. >
  70. {
  71.     pass p0
  72.     <
  73.         // stream mapping
  74.         string streammap = "stream1";
  75.     >
  76.     {
  77.         AlphaRef = <cAlphaRef>;
  78.         CullMode = <cCullMode>;
  79.     
  80.         VertexShader = compile vs_1_1 VS();
  81.         PixelShader  = compile ps_1_1 PS();
  82.     }
  83. }
  84. //---------------------------------------------------------------------------
  85. // Basic technique - vertex shader, no pixel shader
  86. technique vs11_ps0
  87. <
  88.     // streams for technique
  89.     string stream1 = "POSITION | LIGHTMAP";
  90. >
  91. {
  92.     pass p0
  93.     <
  94.         // stream mapping
  95.         string streammap = "stream1";
  96.     >
  97.     {
  98.         AlphaRef = <cAlphaRef>;
  99.         CullMode = <cCullMode>;
  100.         TextureFactor = <cDiffuse>;
  101.  
  102.         VertexShader = compile vs_1_1 VS();
  103.         
  104.         Sampler[0] = <lightmap_sampler>;
  105.         ColorOp[0] = Modulate;
  106.         ColorArg1[0] = TFactor;
  107.         ColorArg2[0] = Texture;
  108.         AlphaOp[0] = Modulate;
  109.         AlphaArg2[0] = TFactor;
  110.         AlphaArg2[0] = Texture;
  111.     }
  112. }
  113. //---------------------------------------------------------------------------
  114. // Basic technique - fixed function
  115. technique vs0_ps0
  116. <
  117.     // streams for technique
  118.     string stream1 = "POSITION | LIGHTMAP";
  119. >
  120. {
  121.     pass p0
  122.     <
  123.         // stream mapping
  124.         string streammap = "stream1";
  125.     >
  126.     {
  127.         // matrices
  128.         WorldTransform[0] = <cMtxW>;
  129.     
  130.         AlphaRef = <cAlphaRef>;
  131.         CullMode = <cCullMode>;
  132.         TextureFactor = <cDiffuse>;
  133.     
  134.         // simple multitexture
  135.         Sampler[0] = <lightmap_sampler>;
  136.         ColorOp[0] = Modulate;
  137.         ColorArg1[0] = TFactor;
  138.         ColorArg2[0] = Texture;
  139.         AlphaOp[0] = Modulate;
  140.         AlphaArg2[0] = TFactor;
  141.         AlphaArg2[0] = Texture;
  142.     }
  143. }
  144. //---------------------------------------------------------------------------
  145.  
  146.  
  147.  
  148.